﻿@model SCMS.UI.Models.ViewWRNDetails
@{AjaxOptions ajaxOpts = new AjaxOptions
  {
      UpdateTargetId = "popup-page",
      LoadingElementId = "popup-loading",
      HttpMethod = "Post",
      Url = Url.Action("ApproveWRO"),
      OnSuccess = "CenterPopup();LoadRequests();"
  };}

<div class="partialViewCard" style="max-width: 1200px; min-width: 900px">
    <div class="partialViewCardHeader"><h3>Warehouse Release Order Approval</h3></div>
    <br />
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
    {
        <h4 style="text-align: center;">@Model.EntityWHouseRelease.RefNumber</h4>
        <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" style="border: 1px solid grey;
            border-collapse: collapse; padding: 5px; font-size: 12px;">
            <tr class="gridheader">
                <th>
                </th>
                <th>
                    Item/Goods Description
                </th>
                <th>
                    UnitMessure
                </th>
                <th>
                    Serial No.
                </th>
                <th>
                    Asset No.
                </th>
                <th>
                    Quantity
                </th>
                <th>
                    Comments
                </th>
            </tr>
            @{int x = 0; string rowClass = ""; int count = 0; string itemName, serialNo, AssetNo; }
            @foreach (var item in Model.writems)
            {
                if (x % 2 == 0) { rowClass = "grideven"; }
                if (x % 2 != 0) { rowClass = "gridodd"; }
                if (item.Inventory.Item.ItemCategory.CategoryCode == "C")
                {
                    itemName = item.Inventory.Item.Name;
                    serialNo = item.Inventory.Item.SerialNumber;
                    AssetNo = "N/A";
                }
                else
                {
                    itemName = item.Asset.Name;
                    serialNo = item.Asset.SerialNumber;
                    AssetNo = item.Asset.AssetNumber;
                }
                if (x >= 0) { x = x + 1; }
                count = count + 1;
                <tr class="gridodd">
                    <td style="width: 5%; text-align: center;">
                        @count
                    </td>
                    <td style="width: 25%; text-align: left;">
                        @*@item.Inventory.Item.Name*@
                        @itemName
                    </td>
                    <td style="width: 13%; text-align: center;">
                        @item.Inventory.Item.UnitOfMeasure.Code
                    </td>
                    <td style="width: 15%; text-align: center;">
                        @*@item.Inventory.Item.SerialNumber*@
                        @serialNo
                    </td>
                    <td style="width: 15%; text-align: left;">
                        @*@item.Asset.AssetNumber*@
                        @AssetNo
                    </td>
                    <td style="width: 15%; text-align: center;">
                        @item.Quantity
                    </td>
                    <td style="width: 10%; text-align: left;">
                        @item.Comments
                    </td>
                </tr>
            }
        </table>
        <br />
        <b style="font-weight: bold; font-size: 12px;">&nbsp;&nbsp;&nbsp;Requestor</b>
        <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
            <tr class="gridheader">
                <th width="20%">Name</th>
                <th width="20%">Title</th>
                <th width="20%">Office</th>
                <th width="20%">Signature</th>
                <th width="20%">Request Date</th>
            </tr>
            <tr>
                <td align="center">
                    @if (Model.EntityWHouseRelease.Staff1 != null)
                    {
                        @Model.EntityWHouseRelease.Staff1.Person.FirstName
                        @Html.Raw("&nbsp;")
                        @Model.EntityWHouseRelease.Staff1.Person.OtherNames
                    }
                </td>
                <td align="center">
                    @if (Model.EntityWHouseRelease.Staff1 != null)
                    {
                        @Model.EntityWHouseRelease.Staff1.Designation.Name
                    }
                </td>
                <td align="center">
                    @if (Model.EntityWHouseRelease.Staff1 != null)
                    {
                        @Model.EntityWHouseRelease.Staff1.CountrySubOffice.Name
                    }
                </td>
                <td align="center">
                    @if (Model.EntityWHouseRelease.Staff1 != null && Model.EntityWHouseRelease.Staff1.Person.SignatureImage != null)
                    {
                        <img src="@Url.Action("Photo", "Person", new { id = Model.EntityWHouseRelease.Staff1.Person.Id, area = "" })" alt="" style="max-width: 150px;" />
                    }
                </td>
                <td align="center">
                    @Model.EntityWHouseRelease.PreparedOn.ToString("dd/MM/yyyy h:mm tt")
                </td>
            </tr>
        </table>
        <br />
        <b style="font-weight: bold; font-size: 12px;">&nbsp;&nbsp;&nbsp;Receipient</b>
        <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
            <tr class="gridheader">
                <th width="33%">Name</th>
                <th width="33%">Title</th>
                <th width="34%">Office</th>
            </tr>
            <tr>
                <td align="center">
                    @if (Model.EntityWHouseRelease.Staff2 != null)
                    {
                        @Model.EntityWHouseRelease.Staff2.Person.FirstName
                        @Html.Raw("&nbsp;")
                        @Model.EntityWHouseRelease.Staff2.Person.OtherNames
                    }
                </td>
                <td align="center">
                    @if (Model.EntityWHouseRelease.Staff2 != null)
                    {
                        @Model.EntityWHouseRelease.Staff2.Designation.Name
                    }
                </td>
                <td align="center">
                    @if (Model.EntityWHouseRelease.Staff2 != null)
                    {
                        @Model.EntityWHouseRelease.Staff2.CountrySubOffice.Name
                    }
                </td>
            </tr>
        </table>
        <br />
        <table width="98%" align="center">
            <tr>
                <td width="50%" align="right">
                    @Html.HiddenFor(w => w.EntityWHouseRelease.Id)
                    <input type="submit" class="btn tertiary" value="Approve" />
                </td>
                <td width="50%">
                    <input type="button" class="btn tertiary" value="Reject" onclick="sendRequest('/RequestReview/LoadRejectWRO/@Model.EntityWHouseRelease.Id', 'popup-page', 'popup-loading'); CenterPopup();" />
                </td>
            </tr>
        </table>
    }
    <br />
</div>
